
class Main {
    var panel, vessel, btnMc, teamBtnMc, _parent, num, _alpha, removeMovieClip, targetShowSmall, index, id, msg, targetShow, _x, _name;
    static var root, bgMc, logs;

    function Main(topVessel) {
        root = topVessel;
        this.init();
    }

    static function turnCount() {
        Main.root.vessel.txt_mc.mc.num_txt.text = _root.upCount;
    }

    function init() {
        datas.XMLVessel.main = this;
        panel = Main.root.createEmptyMovieClip("panel", 2);
        vessel = Main.root.createEmptyMovieClip("vessel", 1);
        vessel.attachMovie("txt_mc", "txt_mc", 4, {_x: 9, _y: 575});
        bgMc = vessel.createEmptyMovieClip("back_mc", 2);
        Main.bgMc._x = 490;
        Main.bgMc._y = 307;
        btnMc = Main.root.attachMovie("btn_mc", "btn_mc", 3, {_y: 250, num: 0});
        Main.root.attachMovie("closeBtn_mc", "closeBtn_mc", 4, {_x: 0, _y: 570});
        Main.root.close_mc.swapDepths(55);
        teamBtnMc = Main.root.btnsmc;
        panel.attachMovie("show_mc", "show_mc", 100);
        panel._y = 650;
        panel._x = 38;
        var _loc6 = {};
        _loc6.onKeyDown = function () {
            if (Key.getCode() == 113) {
                Main.logs.__set__visible(!Main.logs.__get__visible());
            }
        };
        Key.addListener(_loc6);
        teamBtnMc.pre_btn.onPress = function () {
            var _loc1 = datas.XMLVessel.main;
            if (_loc1.panelPage - 9 >= 0) {
                for (var _loc3 in _loc1.panel) {
                    if (_loc1.panel[_loc3]._name != "show_mc") {
                        _loc1.panel[_loc3].removeMovieClip();
                    }
                }
                _loc1.panelPage = _loc1.panelPage - 9;
                _loc1.btnMc.num = 8;
                for (var _loc2 = _loc1.panelPage;_loc2 < _loc1.panelPage + 9; ++_loc2) {
                    _loc1.fillPanel(_loc2);
                }
                _loc1.fillVessel(_loc1.panel.mc_8.targetShow, _loc1.panel.mc_8.msg, _loc1.panel.mc_8.id, _loc1.panel.mc_8.index, _loc1.panel.mc_8.targetShowSmall);
                _loc1.panel.show_mc._x = _loc1.panel.mc_8._x;                
            }
        };
        teamBtnMc.next_btn.onPress = function () {
            var _loc1 = datas.XMLVessel.main;
            if (_loc1.panelPage + 9 < datas.XMLVessel.picSortArray.length) {
                _loc1.btnMc.num = 0;
                for (var _loc3 in _loc1.panel) {
                    if (_loc1.panel[_loc3]._name != "show_mc") {
                        _loc1.panel[_loc3].removeMovieClip();
                    }
                }
                _loc1.panelPage = _loc1.panelPage + 9;
                for (var _loc2 = _loc1.panelPage;_loc2 < _loc1.panelPage + 9; ++_loc2) {
                    _loc1.fillPanel(_loc2);
                }
                _loc1.fillVessel(_loc1.panel.mc_0.targetShow, _loc1.panel.mc_0.msg, _loc1.panel.mc_0.id, _loc1.panel.mc_0.index, _loc1.panel.mc_0.targetShowSmall);
                _loc1.panel.show_mc._x = _loc1.panel.mc_0._x;                
            }
        };
        btnMc.pre_btn.onPress = function () {
            var _loc2 = datas.XMLVessel.main;
            if (_parent.num - 1 >= 0) {
                _parent.num = _parent.num - 1;
                _loc2.panel["mc_" + _parent.num].onPress();
            }else {
                Main.root.btnsmc.pre_btn.onPress();
            }
        };
        btnMc.next_btn.onPress = function () {
            var _loc3 = datas.XMLVessel.main;
            if (_parent.num + 1 < 9 && _loc3.panel["mc_" + (_parent.num + 1)]) {
                _parent.num = _parent.num + 1;
                _loc3.panel["mc_" + _parent.num].onPress();
            }else {
                _loc3 = datas.XMLVessel.main;
                if (_loc3.panelPage + 9 < datas.XMLVessel.picSortArray.length) {
                    _loc3.btnMc.num = 0;
                    for (var _loc5 in _loc3.panel) {
                        if (_loc3.panel[_loc5]._name != "show_mc") {
                            _loc3.panel[_loc5].removeMovieClip();
                        }
                    }
                    _loc3.panelPage = _loc3.panelPage + 9;
                    for (var _loc4 = _loc3.panelPage;_loc4 < _loc3.panelPage + 9; ++_loc4) {
                        _loc3.fillPanel(_loc4);
                    }
                    _loc3.fillVessel(_loc3.panel.mc_0.targetShow, _loc3.panel.mc_0.msg, _loc3.panel.mc_0.id, _loc3.panel.mc_0.index, _loc3.panel.mc_0.targetShowSmall);
                    _loc3.panel.show_mc._x = _loc3.panel.mc_0._x;
                }else {
                    upBoolean = false;
                    for (var _loc4 = 0;_loc4 < datas.XMLVessel.CategroyArray.length; ++_loc4) {
                        if (datas.XMLVessel.picData.id == datas.XMLVessel.CategroyArray[_loc4]) {
                            if (datas.XMLVessel.CategroyArray[_loc4 + 1]) {
                                datas.XMLVessel.loadXML(datas.XMLVessel.CategroyArray[_loc4 + 1]);
                                _loc3.panelPage = 0;
                                return;
                            }else {
                                _root.endBoolean = true;
                                Main.root.close_mc.close_btn.onPress();
                            }
                            return;
                        }
                    }
                    _loc3.panelPage = 0;
                    datas.XMLVessel.loadXML(datas.XMLVessel.CategroyArray[0]);
                }
            }
        };
        
        Main.root.picId = _root.js_picId;
        Main.root.logs.text = Main.root.logs.text + ("id:" + _root.js_groupId);
        datas.XMLVessel.loadXML(_root.js_groupId);
        datas.XMLVessel.loadMainXML(Main.root.categoryXml);
    }

    function fillPanel(num) {
        if (num - panelPage < 9) {
            if (num == 0) {
                var _loc6 = new TextFormat();
                var _loc2 = Main.root.createEmptyMovieClip("tip_mc", Main.root.getNextHighestDepth());
                var _loc3 = _loc2.createTextField("tip_txt", 1, 0, 0, 50, 35);
                _loc3.selectable = false;
                _loc3.autoSize = true;
                _loc3.wordWrap = false;
                _loc3.textColor = 16777215;
                _loc6.size = 18;
                _loc6.bold = true;
                _loc3.setNewTextFormat(_loc6);
                _loc3.text = datas.XMLVessel.picData.msg;
                _loc2.beginFill(10066329, 50);
                _loc2.moveTo(0, 0);
                _loc2.lineTo(_loc3._width, 0);
                _loc2.lineTo(_loc3._width, _loc3._height);
                _loc2.lineTo(0, _loc3._height);
                _loc2.lineTo(0, 0);
                _loc2.endFill();
                _loc2._x = (980 - _loc2._width) / 2;
                _loc2._y = (714 - _loc2._height) / 2;
                _loc2.num = getTimer();
                _loc2.onEnterFrame = function () {
                    _alpha = int((3000 - (getTimer() - this.num)) / 3000 * 100);
                    if (getTimer() - this.num >= 3000) {
                        this.removeMovieClip();
                    }
                };
            }
            var _loc7 = datas.XMLVessel.picData[datas.XMLVessel.picSortArray[num]].small;
            if (!_loc7) {
                return;
            }
            var _loc4 = panel.attachMovie("back_mc", "mc_" + (num - panelPage), num - panelPage);
            var _loc5 = _loc4.attachMovie("loadmc", "load_mc", 1);
            _loc5._x = (94 - _loc5._width) / 2;
            _loc5._y = (64 - _loc5._height) / 2;
            _loc5._xscale = _loc5._yscale = 50;
            _loc4.targetShow = datas.XMLVessel.picData[datas.XMLVessel.picSortArray[num]].big;
            _loc4.targetShowSmall = datas.XMLVessel.picData[datas.XMLVessel.picSortArray[num]].small;
            _loc4.msg = datas.XMLVessel.picData[datas.XMLVessel.picSortArray[num]].msg;
            _loc4.id = datas.XMLVessel.picData[datas.XMLVessel.picSortArray[num]].id;
            _loc4.index = num;
            var _loc8 = new Picvessel(false);
            _loc8.load(_loc7, _loc4.createEmptyMovieClip("vessel", 2));
            _loc4._x = (num - panelPage) * 102;
            _loc4.onPress = function () {
                datas.XMLVessel.main.fillVessel(targetShow, msg, id, index, targetShowSmall);
                _parent.show_mc._x = _x;
                Main.root.btn_mc.num = Number(_name.substr(3));
            };
            if (firstBoolean){
            }
        }
    }

    function fillVessel(url, msg, id, index, urlSmall) {
        if (index == 0) {
            btnMc.pre_btn._visible = false;
        }else {
            btnMc.pre_btn._visible = true;
        }
        if (_root.loadControl == 3) {
            _root.xianzhiPicNum = 0;
            _root.loadPics();
        }
        Main.bgMc._alpha = 100;
        var _loc5 = new MovieClipLoader();
        var _loc4 = {};
        _loc4.onLoadInit = function (target_mc) {
            target_mc._x = -target_mc._width / 2;
            target_mc._y = -target_mc._height / 2;
        };
        _loc5.addListener(_loc4);
        _loc5.loadClip(urlSmall, Main.bgMc.createEmptyMovieClip("mc", 1));
        vessel.mc.removeMovieClip();
        vessel.load_mc.removeMovieClip();
        delete vessel.loader;
        vessel.createEmptyMovieClip("mc", 3);
        vessel.mc._y = -50;
        var _loc3 = vessel.attachMovie("loadmc", "load_mc", 1);
        _loc3._x = (980 - _loc3._width) / 2;
        _loc3._y = (612 - _loc3._height) / 2;
        vessel.loader = new Picvessel(true);
        vessel.loader.load(url, vessel.mc.createEmptyMovieClip("mc", 1));
        vessel.txt_mc.msg.text = msg == undefined ? ("") : (msg);
        _root.js_imgIndex = id;
    }

    var panelPage = 0;
    var firstBoolean = true;
    static var upBoolean = false;
    static var filterBoolean = true;
}
